import org.apache.spark.sql.SparkSession

val spark = SparkSession.builder.appName("SparkSQL-DataInsertion").master("local[*]").getOrCreate()
val data = Seq(("Alice", "Smith", 22, "Computer Science", "2020-09-01")).toDF("first_name", "last_name", "age", "major", "enrollment_date")
data.write
.format("jdbc")
.option("url", "jdbc:mysql://localhost:3306/sparksql_practice")
.option("dbtable", "students")
.option("user", "root")
.option("password", "root")
.option("driver", "com.mysql.jdbc.Driver")
.option("useSSL", "false")
.mode("append")
.save()

